<%@ page contentType="text/html; charset=UTF-8" language="java" pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp"%>
<%@include file="/common/javascript.jsp" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>员工</title>
    <script type="text/javascript">
    var dialog;
    var mainform;
    var viewType = "${viewType}";

    $(function (){
    	
        $("#deptAbr").ligerComboBox({
            onBeforeOpen: selectDept,width:300
        });
        
        mainform=$("#mainform");
        
        mainform.ligerForm();
        
        if(viewType=="modify"){
        	 $("#empId").attr("readonly", "readonly").removeAttr("validate");
        }
        
        if(viewType=="detail"){
        	$("input,select,textarea",mainform).attr("readonly", "readonly");
        }else{
            $.metadata.setType("attr", "validate");
            LG.validate(mainform);
        }
        
        LG.setFormDefaultBtn(cancel,viewType=="detail" ? null : save);

    });
   
    function save(){
        LG.submitForm(mainform, function (result) {
        	if(typeof(result)=="string"){
        		result=eval("("+result+")");
        	}
            if (!result.success) {
                LG.showError('错误:' + data.message);
            }
            else { 
                LG.showSuccess('保存成功', function () { 
                   LG.callParent("empList");
                });
            }
        });
    }
    function cancel(){
        var win = window.parent || window;
        if(win.dialog){
        	win.dialog.close();
        }
    }
    
    function selectDept()
    {
    	dialog=$.ligerDialog.open({title: '选择部门',showMax: true, showToggle: true, showMin: true, isResize: true, modal: true,name:'winselector',width:600, height: 300, url: '${ctx}/dept/toRadioDept'});
    }
    
    function callBackCancel(){
    	dialog.close();
    }
    
    function callBackOK(row){
       	$("#deptId").val(row.deptId);
       	$("#deptAbr").val(row.deptAbr);
        dialog.close();
   }
 </script>
</head>

<body>
    <form name="mainform" method="post"  id="mainform" action="${ctx }/emp/save">
        <input type="hidden" name="viewType" value="${viewType}"/>
        <table cellpadding="0" cellspacing="0" class="l-table-edit" style="width: 100%;">
            <tr>
                <td align="left" class="l-table-edit-td">工号:</td>
                <td align="left" class="l-table-edit-td" style="width:160px" >
                	<input name="empId" type="text" id="empId" value="${command.empId }" ltype="text" validate="{required:true,minlength:3,maxlength:10,notnull:true}" nullText="不能为空!"/>
                </td>
                <td align="left"></td>
                
                <td align="left" class="l-table-edit-td" valign="top">在职:</td>
                <td align="left" class="l-table-edit-td" style="width:160px">
                	<c:choose>
                		<c:when test="${command.isResign eq 'F' }">
                			<input id="isEnable" type="checkbox" name="isEnable" value="F" onchange="changeTnf(this)"/> 
                		</c:when>
                		<c:otherwise>
                			<input id="isEnable" type="checkbox" name="isEnable" value="T" checked="checked"  onchange="changeTnf(this)"/> 
                		</c:otherwise>
                	</c:choose>
                </td>
                <td align="left"></td>
            </tr>
            <tr>
                <td align="left" class="l-table-edit-td" valign="top">中文姓名:</td>
                <td align="left" class="l-table-edit-td" style="width:160px">
                	<input name="empNameC" type="text" id="empNameC" value="${command.empNameC }" ltype="text" validate="{required:true,maxlength:100,notnull:true}" nullText="不能为空!"/>
                </td>
                <td align="left"></td>
                
                <td align="left" class="l-table-edit-td" valign="top">到职日期:</td>
                <td align="left" class="l-table-edit-td" style="width:160px">
                	<input type="text" name="dateReg" id="dateReg" value="${command.dateReg }" ltype="date" validate="{required:true}" nullText="不能为空!"/>
                </td>
                <td align="left"></td>
            </tr>
            <tr>
                <td align="left" class="l-table-edit-td" valign="top">英文姓名:</td>
                <td align="left" class="l-table-edit-td" style="width:160px">
                	<input name="empNameE" type="text" id="empNameE" value="${command.empNameE }" ltype="text" validate="{required:true,maxlength:100,notnull:true}" nullText="不能为空!"/>
                </td>
                <td align="left"></td>
                
                <td align="left" class="l-table-edit-td" valign="top">离职日期:</td>
                <td align="left" class="l-table-edit-td" style="width:160px">
                	<input type="text" name="dateRsn" id="dateRsn" value="${command.dateRsn }" ltype="date"/>
                </td>
                <td align="left"></td>
            </tr>
            <tr>
                <td align="left" class="l-table-edit-td" valign="top">邮箱:</td>
                <td align="left" class="l-table-edit-td" style="width:160px">
                	<input name="empEmail" type="text" id="empEmail" value="${command.empEmail}" ltype="text" validate="{required:true,maxlength:100,notnull:true}" nullText="不能为空!"/>
                </td>
                <td align="left"></td>
                
                <td align="left" class="l-table-edit-td" valign="top">生日:</td>
                <td align="left" class="l-table-edit-td" style="width:160px">
                	<input type="text" name="dateBirth" id="dateBirth" value="${command.dateBirth }" ltype="date" validate="{required:true}" nullText="不能为空!"/>
                </td>
                <td align="left"></td>
            </tr>
            
            <tr>
                <td align="left" class="l-table-edit-td" valign="top">职称:</td>
                <td align="left" class="l-table-edit-td" style="width:160px">
                	<select name="empTitle">
                		<c:forEach items="${empTitles}" var="dt">
                			<c:choose>
                				<c:when test="${command.empTitle eq dt.id.tdId }">
                					<option value="${dt.id.tdId }" selected="selected">${dt.tdName }</option>
                				</c:when>
                				<c:otherwise>
                					<option value="${dt.id.tdId }">${dt.tdName }</option>
                				</c:otherwise>
                			</c:choose>
                		</c:forEach>
                	</select>
                </td>
                <td align="left"></td>
                
                <td align="left" class="l-table-edit-td" valign="top">属性:</td>
                <td align="left" class="l-table-edit-td" style="width:160px">
                	<select name="empType">
                		<c:forEach items="${empTypes}" var="dt">
                			<c:choose>
                				<c:when test="${command.empType eq et.id.tdId }">
                					<option value="${dt.id.tdId }" selected="selected">${dt.tdName }</option>
                				</c:when>
                				<c:otherwise>
                					<option value="${dt.id.tdId }">${dt.tdName }</option>
                				</c:otherwise>
                			</c:choose>
                		</c:forEach>
                	</select>
                </td>
                <td align="left"></td>
            </tr>
            
            <tr>
                <td align="left" class="l-table-edit-td">部门:</td>
                <td align="left" class="l-table-edit-td" colspan="4">
                	<input type="hidden" name="department.deptId" value="${command.department.deptId}" id="deptId" />
                	<input type="text" value="${command.department.deptAbr}" id="deptAbr" validate="{required:true,notnull:true}" nullText="不能为空!"/>
                </td> 
                <td align="left"></td>
            </tr>
            <tr>
                <td align="left" class="l-table-edit-td">备注:</td>
                <td align="left" class="l-table-edit-td" colspan="4"> 
                <textarea cols="100" rows="3" class="l-textarea" id="remark" name="remark" style="width:400px">${command.remark}</textarea>
                </td> <td align="left"></td>
           </tr>
           
           <tr>
                <td align="left" class="l-table-edit-td" valign="top">建档人:</td>
                <td align="left" class="l-table-edit-td" style="width:160px"></td>
                <td align="left"></td>
                
                <td align="left" class="l-table-edit-td" valign="top">修改人:</td>
                <td align="left" class="l-table-edit-td" style="width:160px"></td>
                <td align="left"></td>
           </tr>
        </table>
    </form>
</body>
</html>
